
cpp_srcs := $(shell find src -name *.cpp)
cpp_i	 := $(patsubst src/%.cpp,src/%.i,$(cpp_srcs))
cpp_s    := $(patsubst src/%.cpp,src/%.s,$(cpp_srcs))
cpp_objs := $(patsubst src/%.cpp,objs/%.o,$(cpp_srcs))


workspace/exec : $(cpp_objs)
	@mkdir -p $(dir $@)
	@g++ $< -o $@

run : workspace/exec
	@./$<

objs/%.o : src/%.cpp
	@mkdir -p $(dir $@)
	@g++ -c $^ -o $@
	
objects : $(cpp_objs)

src/%.i : src/%.cpp
	@g++ -E $< -o $@

preprocess : $(cpp_i)

src/%.s : src/%.cpp
	@g++ -S $< -o $@

assemble : $(cpp_s)

debug :
	@echo $(cpp_i)

clean:
	@rm -rf $(cpp_i) $(cpp_s) objs workspace

.PHONY : debug predebug assemble clean
